.class public Lcom/zuiapps/suite/utils/security/TestDES;
.super Ljava/lang/Object;
.source "TestDES.java"


# instance fields
.field key:Ljava/security/Key;


# direct methods
.method public constructor <init>(Ljava/lang/String;)V
    .registers 2
    .param p1, "str"    # Ljava/lang/String;

    .prologue
    .line 15
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 16
    invoke-virtual {p0, p1}, Lcom/zuiapps/suite/utils/security/TestDES;->getKey(Ljava/lang/String;)V

    .line 17
    return-void
.end method


# virtual methods
.method public decrypt(Ljava/lang/String;Ljava/lang/String;)V
    .registers 11
    .param p1, "file"    # Ljava/lang/String;
    .param p2, "dest"    # Ljava/lang/String;
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 66
    const-string v6, "DES"

    invoke-static {v6}, Ljavax/crypto/Cipher;->getInstance(Ljava/lang/String;)Ljavax/crypto/Cipher;

    move-result-object v1

    .line 67
    .local v1, "cipher":Ljavax/crypto/Cipher;
    const/4 v6, 0x2

    iget-object v7, p0, Lcom/zuiapps/suite/utils/security/TestDES;->key:Ljava/security/Key;

    invoke-virtual {v1, v6, v7}, Ljavax/crypto/Cipher;->init(ILjava/security/Key;)V

    .line 68
    new-instance v3, Ljava/io/FileInputStream;

    invoke-direct {v3, p1}, Ljava/io/FileInputStream;-><init>(Ljava/lang/String;)V

    .line 69
    .local v3, "is":Ljava/io/InputStream;
    new-instance v4, Ljava/io/FileOutputStream;

    invoke-direct {v4, p2}, Ljava/io/FileOutputStream;-><init>(Ljava/lang/String;)V

    .line 70
    .local v4, "out":Ljava/io/OutputStream;
    new-instance v2, Ljavax/crypto/CipherOutputStream;

    invoke-direct {v2, v4, v1}, Ljavax/crypto/CipherOutputStream;-><init>(Ljava/io/OutputStream;Ljavax/crypto/Cipher;)V

    .line 71
    .local v2, "cos":Ljavax/crypto/CipherOutputStream;
    const/16 v6, 0x400

    new-array v0, v6, [B

    .line 73
    .local v0, "buffer":[B
    :goto_1f
    invoke-virtual {v3, v0}, Ljava/io/InputStream;->read([B)I

    move-result v5

    .local v5, "r":I
    if-ltz v5, :cond_2a

    .line 74
    const/4 v6, 0x0

    invoke-virtual {v2, v0, v6, v5}, Ljavax/crypto/CipherOutputStream;->write([BII)V

    goto :goto_1f

    .line 76
    :cond_2a
    invoke-virtual {v2}, Ljavax/crypto/CipherOutputStream;->close()V

    .line 77
    invoke-virtual {v4}, Ljava/io/OutputStream;->close()V

    .line 78
    invoke-virtual {v3}, Ljava/io/InputStream;->close()V

    .line 79
    return-void
.end method

.method public encrypt(Ljava/lang/String;Ljava/lang/String;)V
    .registers 11
    .param p1, "file"    # Ljava/lang/String;
    .param p2, "destFile"    # Ljava/lang/String;
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 42
    const-string v6, "DES"

    invoke-static {v6}, Ljavax/crypto/Cipher;->getInstance(Ljava/lang/String;)Ljavax/crypto/Cipher;

    move-result-object v1

    .line 44
    .local v1, "cipher":Ljavax/crypto/Cipher;
    const/4 v6, 0x1

    iget-object v7, p0, Lcom/zuiapps/suite/utils/security/TestDES;->key:Ljava/security/Key;

    invoke-virtual {v1, v6, v7}, Ljavax/crypto/Cipher;->init(ILjava/security/Key;)V

    .line 45
    new-instance v3, Ljava/io/FileInputStream;

    invoke-direct {v3, p1}, Ljava/io/FileInputStream;-><init>(Ljava/lang/String;)V

    .line 46
    .local v3, "is":Ljava/io/InputStream;
    new-instance v4, Ljava/io/FileOutputStream;

    invoke-direct {v4, p2}, Ljava/io/FileOutputStream;-><init>(Ljava/lang/String;)V

    .line 47
    .local v4, "out":Ljava/io/OutputStream;
    new-instance v2, Ljavax/crypto/CipherInputStream;

    invoke-direct {v2, v3, v1}, Ljavax/crypto/CipherInputStream;-><init>(Ljava/io/InputStream;Ljavax/crypto/Cipher;)V

    .line 48
    .local v2, "cis":Ljavax/crypto/CipherInputStream;
    const/16 v6, 0x400

    new-array v0, v6, [B

    .line 50
    .local v0, "buffer":[B
    :goto_1f
    invoke-virtual {v2, v0}, Ljavax/crypto/CipherInputStream;->read([B)I

    move-result v5

    .local v5, "r":I
    if-lez v5, :cond_2a

    .line 51
    const/4 v6, 0x0

    invoke-virtual {v4, v0, v6, v5}, Ljava/io/OutputStream;->write([BII)V

    goto :goto_1f

    .line 53
    :cond_2a
    invoke-virtual {v2}, Ljavax/crypto/CipherInputStream;->close()V

    .line 54
    invoke-virtual {v3}, Ljava/io/InputStream;->close()V

    .line 55
    invoke-virtual {v4}, Ljava/io/OutputStream;->close()V

    .line 56
    return-void
.end method

.method public getKey(Ljava/lang/String;)V
    .registers 7
    .param p1, "strKey"    # Ljava/lang/String;

    .prologue
    .line 24
    :try_start_0
    const-string v2, "DES"

    invoke-static {v2}, Ljavax/crypto/KeyGenerator;->getInstance(Ljava/lang/String;)Ljavax/crypto/KeyGenerator;

    move-result-object v0

    .line 25
    .local v0, "_generator":Ljavax/crypto/KeyGenerator;
    new-instance v2, Ljava/security/SecureRandom;

    invoke-virtual {p1}, Ljava/lang/String;->getBytes()[B

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/security/SecureRandom;-><init>([B)V

    invoke-virtual {v0, v2}, Ljavax/crypto/KeyGenerator;->init(Ljava/security/SecureRandom;)V

    .line 26
    invoke-virtual {v0}, Ljavax/crypto/KeyGenerator;->generateKey()Ljavax/crypto/SecretKey;

    move-result-object v2

    iput-object v2, p0, Lcom/zuiapps/suite/utils/security/TestDES;->key:Ljava/security/Key;
    :try_end_18
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_18} :catch_19

    .line 31
    return-void

    .line 28
    .end local v0    # "_generator":Ljavax/crypto/KeyGenerator;
    :catch_19
    move-exception v1

    .line 29
    .local v1, "e":Ljava/lang/Exception;
    new-instance v2, Ljava/lang/RuntimeException;

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "Error initializing SqlMap class. Cause: "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw v2
.end method
